home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / madtrb9.arc / BENCHMRK.PAS next >
Encoding:
Pascal/Delphi Source File  |  1985-12-12  |  2.6 KB  |  60 lines

  1. PROGRAM BENCH_MARK;
  2. {  This program was converted from BASIC into Pascal.
  3.  
  4.    FLOATING-POINT BENCHMARK
  5.  
  6.    The following is a program to test the accuracy of floating
  7.    point functions (from Sept. DR DOBBS):
  8.       10 A=1
  9.       20 FOR I%=1 TO 2499
  10.       30   A=TAN(ATN(EXP(LOG(SQR(A*A))))) + 1
  11.       40 NEXT
  12.       50 PRINT A
  13.       60 STOP
  14.  
  15.    The correct printout is A=2500 exactly.
  16.  
  17.    IBM-PC BASIC 1.0 fails miserably, giving A=2179.8 (only 1 sig-
  18.    nificant figure of accuracy!).  In contrast, an APPLE II or
  19.    Commodore 64 gives 2500 to at least 7 figures. Using the 8087
  20.    with a polyFORTH version of the benchmark, I obtained 2500 to
  21.    13 figures in 5.0 seconds. (NOTE: See March,84 D. DOBBS for
  22.    the results aginst many systems.)
  23. }
  24.  
  25.  
  26. VAR
  27.   a : REAL;
  28.   i : INTEGER;
  29.  
  30. BEGIN
  31.  writeln('  This program was converted from BASIC into Pascal.              ');
  32.  writeln('                                                                  ');
  33.  writeln('   FLOATING-POINT BENCHMARK                                       ');
  34.  writeln('                                                                  ');
  35.  writeln('   The following is a program to test the accuracy of floating    ');
  36.  writeln('   point functions (from Sept. DR DOBBS):                         ');
  37.  writeln('      10 A=1                                                      ');
  38.  writeln('      20 FOR I%=1 TO 2499                                         ');
  39.  writeln('      30   A=TAN(ATN(EXP(LOG(SQR(A*A))))) + 1                     ');
  40.  writeln('      40 NEXT                                                     ');
  41.  writeln('      50 PRINT A                                                  ');
  42.  writeln('      60 STOP                                                     ');
  43.  writeln('                                                                  ');
  44.  writeln('   The correct printout is A=2500 exactly.                        ');
  45.  writeln('                                                                  ');
  46.  writeln('   IBM-PC BASIC 1.0 fails miserably, giving A=2179.8 (only 1 sig- ');
  47.  writeln('   nificant figure of accuracy!).  In contrast, an APPLE II or    ');
  48.  writeln('   Commodore 64 gives 2500 to at least 7 figures. Using the 8087  ');
  49.  writeln('   with a polyFORTH version of the benchmark, I obtained 2500 to  ');
  50.  writeln('   13 figures in 5.0 seconds. (NOTE: See March,84 D. DOBBS for    ');
  51.  writeln('   the results aginst many systems.)                              ');
  52.  a:=1;
  53.  FOR i:= 1 TO 2499 DO
  54.   BEGIN
  55.     a:= ARCTAN( EXP( LN(SQRT(a * a)) ) );
  56.     a:= (SIN(a) / COS(a)) + 1;
  57.   END;
  58.   WRITELN(a:3:11);
  59. END.
  60.